package cn.tedu.property_management_system.controller;

import cn.tedu.property_management_system.entity.DTO.UserDTO;
import cn.tedu.property_management_system.entity.User;
import cn.tedu.property_management_system.entity.UserExample;
import cn.tedu.property_management_system.mapper.UserMapper;
import cn.tedu.property_management_system.service.IUserService;
import cn.tedu.property_management_system.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;

    @PostMapping("/login")
    public JsonResult<String> selectByusername(@RequestBody UserDTO userDTO) throws IOException {
        log.debug("用户试图登录,登录信息为:[{}]",userDTO);
        String jwt = userService.login(userDTO);
        return JsonResult.OK(jwt);
    }

}
